package com.java98k.alipayDemo.controller;

import com.alipay.api.AlipayApiException;
import com.java98k.alipayDemo.bean.AlipayBean;
import com.java98k.alipayDemo.service.PayService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/* 订单接口 */
@RestController()
@RequestMapping("order")
public class OrderController {
    @Resource
    private PayService payService;//调用支付服务

    /*阿里支付*/

    @PostMapping(value = "alipay")


    /**
     * @Author: 李锦龙
     * @Description: TODO
     * @Date 2021/9/16 11:25
     * @param outTradeNo 商户订单号，必填
     * @param subject 订单名称，必填
     * @param totalAmount 付款金额，必填
     * @param body 商品描述，可空
     * @return java.lang.String
     **/
    public String alipay(String outTradeNo,String subject,StringBuffer totalAmount,String body) throws AlipayApiException {

        return payService.aliPay(AlipayBean.builder()
                .body(body)
                .out_trade_no(outTradeNo)
                .total_amount(totalAmount)
                .subject(subject).build());
    }
}
